package com.shuai.jit.controller;

import com.shuai.jit.entity.R;
import com.shuai.jit.service.impl.OssServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@RestController
@Api("上传服务")
public class OssController {

    @Autowired
    OssServiceImpl ossService;

    @RequestMapping("/upload")
    @ApiOperation("上传头像")
    public R uploadOssFile(@ApiParam(name = "file", value = "头像文件", required = true) @RequestParam("file") MultipartFile file) {
        //上传文件，返回文件url
        String url = ossService.uploadFileAvatar(file);
        return R.ok().data("url", url);
    }
}
